home *** CD-ROM | disk | FTP | other *** search
Wrap
//COPYRIGHT var nStyle = new Array; var hStyle = new Array; var nLayer = new Array; var hLayer = new Array; var nTCode = new Array; var AnimStep = 0; var AnimHnd = 0; var HTHnd = new Array; var DoFormsTweak = false; var mFrame; var cFrame; var OpenMenus = new Array; var SelCommand; var nOM = 0; var mX; var mY; var xOff = 0; var HideSpeed = 200; //BROWSERDETECTION if ((frames.length==0) && IsMac) frames.top = window; if(IE) xOff = 2; //CODEFRAME //FX //STYLECODE function GetCurCmd() { //IE //This function will return the current command under the mouse pointer. //It will return null if the mouse is not over any command. //------------------------------ //Version 1.3 // var cc = mFrame.window.event.srcElement; while((cc.id=="") && (cc.tagName!="TD")) { cc = cc.parentElement; if(cc==null) break; } return cc; } function HoverSel(mode, imgLName, imgRName) { //IE //This is the function called every time the mouse pointer is moved over a command. //------------------------------ //mode: 0 if the mouse is moving over the command and 1 if is moving away. //imgLName: Name of the left image object, if any. //imgRName: Name of the right image object, if any. //------------------------------ //Version 9.3 // var imgL = new Image; var imgLRsc = new Image; var imgR = new Image; var imgRRsc = new Image; var mc; if(mode==0 && OpenMenus[nOM].SelCommand!=null) HoverSel(1); if(imgLName!="_") var imgL = eval("mFrame.document.images['"+imgLName+"']"); if(imgRName!="_") var imgR = eval("mFrame.document.images['"+imgRName+"']"); if(mode==0) { mc = GetCurCmd(); if(nOM>1) if(mc==OpenMenus[nOM-1].SelCommand) return false; if(OpenMenus[nOM].SelCommand || nOM>1) while(!InMenu()) Hide(); mc.style.cssText = hStyle[mc.id]; if(imgLName!='_') imgLRsc = eval(imgLName+"On"); if(imgRName!='_') imgRRsc = eval(imgRName+"On"); OpenMenus[nOM].SelCommand = mc; OpenMenus[nOM].SelCommandPar = [imgLName,imgRName]; } else { mc = (mode==1)?OpenMenus[nOM].SelCommand:OpenMenus[nOM].Opener; imgLName = (mode==1)?OpenMenus[nOM].SelCommandPar[0]:OpenMenus[nOM].OpenerPar[0]; imgRName = (mode==1)?OpenMenus[nOM].SelCommandPar[1]:OpenMenus[nOM].OpenerPar[1]; mc.style.background = ""; mc.style.cssText = nStyle[mc.id]; if(imgLName!='_') imgLRsc = eval(imgLName+"Off"); if(imgRName!='_') imgRRsc = eval(imgRName+"Off"); window.status = ""; OpenMenus[nOM].SelCommand = null; } if(imgLName!='_') { imgL = eval("mFrame.document.images."+imgLName); imgL.src = imgLRsc.src; } if(imgRName!='_') { imgR = eval("mFrame.document.images."+imgRName); imgR.src = imgRRsc.src; } return true; } function NSHoverSel(mode, mc, bcolor, w, h) { //NS //This is the function called every time the mouse pointer is moved over or away from a command. //------------------------------ //mode: 0 if the mouse is moving over the command and 1 if is moving away. //mc: Name of the layer that corresponds to the selected command. //n: Unique ID that identifies this command. Used to retrieve the data from the nLayer or hLayer array. //bcolor: Background color of the command. Ignored if the group uses a background image. //w: Width of the command's layer. //h: Height of the command's layer. //------------------------------ //Version 10.5 // var n; var LayerHTM; if(mode==0 && OpenMenus[nOM].SelCommand!=null) NSHoverSel(1); if(mode==0) { n = CBparseInt(mc.name.substr(2)); if(nOM>1) if(mc==OpenMenus[nOM-1].SelCommand) return false; while(!InMenu()) Hide(); LayerHTM = hLayer[n]; OpenMenus[nOM].SelCommand = mc; OpenMenus[nOM].SelCommandPar = [mc.bgColor,w,h]; mc.bgColor = bcolor; } else { mc = (mode==1)?OpenMenus[nOM].SelCommand:OpenMenus[nOM].Opener; bcolor = (mode==1)?OpenMenus[nOM].SelCommandPar[0]:OpenMenus[nOM].OpenerPar[0]; w = (mode==1)?OpenMenus[nOM].SelCommandPar[1]:OpenMenus[nOM].OpenerPar[1]; h = (mode==1)?OpenMenus[nOM].SelCommandPar[2]:OpenMenus[nOM].OpenerPar[2]; n = CBparseInt(mc.name.substr(2)); LayerHTM = nLayer[n]; if(mc.parentLayer.background.src!="") mc.bgColor = null; else mc.bgColor = bcolor; window.status = ""; OpenMenus[nOM].SelCommand = null; } mc.resizeTo(w,h); mc.document.open(); mc.document.write(LayerHTM); mc.document.close(); return true; } function Hide() { //IE,NS //This function hides the last opened group and it keeps hiding all the groups until //no more groups are opened or the mouse is over one of them. //Also takes care of reseting any highlighted commands. //------------------------------ //Version 3.2 // if(AnimHnd) window.clearTimeout(AnimHnd); if(OpenMenus[nOM].SelCommand!=null) { if(IE) HoverSel(1); if(NS) NSHoverSel(1); } if(OpenMenus[nOM].Opener!=null) { if(IE) HoverSel(3); if(NS) NSHoverSel(3); } OpenMenus[nOM].visibility = "hidden"; window.clearTimeout(HTHnd[nOM]); HTHnd[nOM] = 0; nOM--; if(nOM>0) if(!InMenu()) HTHnd[nOM] = window.setTimeout("Hide()", HideSpeed); if(nOM==0) FormsTweak("visible"); } function ShowMenu(mName, x, y, isCascading) { //IE,NS //This is the main function to show the menus when a hotspot is triggered or a cascading command is activated. //------------------------------ //mName: Name of the <div> or <layer> to be shown. //x: Left position of the menu. //y: Top position of the menu. //isCascading: True if the menu has been triggered from a command, and not from a hotspot. //------------------------------ //Version 14.0 // x = CBparseInt(x); y = CBparseInt(y); if(AnimHnd && nOM>0) { AnimStep=100; Animate(); } if(IE) var Menu = mFrame.document.all[mName]; if(NS) var Menu = mFrame.document.layers[mName]; if(!Menu) return false; if(IE) Menu = Menu.style; if(Menu==OpenMenus[nOM] || HTHnd[nOM]) return false; Menu.Opener = nOM>0?OpenMenus[nOM].SelCommand:null; Menu.OpenerPar = nOM>0?OpenMenus[nOM].SelCommandPar:null; Menu.SelCommand = null; if(!isCascading) HideAll(); var pW = GetWidthHeight()[0] + GetLeftTop()[0]; var pH = GetWidthHeight()[1] + GetLeftTop()[1]; if(IE) { if(isCascading) { x = CBparseInt(OpenMenus[nOM].left) + CBparseInt(OpenMenus[nOM].width) - 6; y = y + CBparseInt(OpenMenus[nOM].top) - 5; Menu.left = (x+CBparseInt(Menu.width)>pW)?CBparseInt(OpenMenus[nOM].left) - CBparseInt(Menu.width) + 6:x; Menu.top = (y+CBparseInt(Menu.height)>pH)?pH - CBparseInt(Menu.height):y; } else { Menu.left = (x+CBparseInt(Menu.width)>pW)?pW - CBparseInt(Menu.width):x; Menu.top = (y+CBparseInt(Menu.height)>pH)?pH - CBparseInt(Menu.height):y; } if(!IsMac) Menu.clip = "rect(0 0 0 0)"; } if(NS) { if(isCascading) { x = OpenMenus[nOM].left + OpenMenus[nOM].clip.width - 6; y = OpenMenus[nOM].top + OpenMenus[nOM].SelCommand.top; x = (x+Menu.w>pW)?OpenMenus[nOM].left - Menu.w + 6:x; y = (y+Menu.h>pH)?pH - Menu.h:y; } else { x = (x+Menu.w>pW)?pW - Menu.w:x; y = (y+Menu.h>pH)?pH - Menu.h:y; } Menu.clip.width = 0; Menu.clip.height = 0; Menu.moveToAbsolute(x,y); } if(isCascading) Menu.zIndex = CBparseInt(OpenMenus[nOM].zIndex) + 1; Menu.visibility = "visible"; OpenMenus[++nOM] = Menu; HTHnd[nOM] = 0; if((IE && !IsMac) || NS) AnimHnd = window.setTimeout("Animate()", 10); FormsTweak("hidden"); return true; } function Animate() { //IE,NS //This function is called by ShowMenu every time a new group must be displayed and produces the predefined unfolding effect. //Currently is disabled for Navigator, because of some weird bugs we found with the clip property of the layers. //------------------------------ //Version 1.9 // var r = ''; var nw = nh = 0; switch(fx) { case 1: if(IE) r = "0 " + AnimStep + "% " + AnimStep + "% 0"; if(NS) nw = AnimStep; nh = AnimStep; break; case 2: if(IE) r = "0 100% " + AnimStep + "% 0"; if(NS) nw = 100; nh = AnimStep; break; case 3: if(IE) r = "0 " + AnimStep + "% 100% 0"; if(NS) nw = AnimStep; nh = 100; break; case 0: if(IE) r = "0 100% 100% 0"; if(NS) nw = 100; nh = 100; break; } with(OpenMenus[nOM]) { if(IE) clip = "rect(" + r + ")"; if(NS) { clip.width = w*(nw/100); clip.height = h*(nh/100); } } AnimStep += 20; if(AnimStep<=100) AnimHnd = window.setTimeout("Animate()",25); else { window.clearTimeout(AnimHnd); AnimStep = 0; AnimHnd = 0; } } function InMenu() { //IE,NS //This function returns true if the mouse pointer is over the last opened menu. //------------------------------ //Version 1.6 // var m = OpenMenus[nOM]; if(!m) return false; if(IE&&BV==4) SetPointerPos(); var l = CBparseInt(m.left) + xOff; var r = l+((IE)?CBparseInt(m.width):m.clip.width) - xOff; var t = CBparseInt(m.top) + xOff; var b = t+((IE)?CBparseInt(m.height):m.clip.height) - xOff; return ((mX>=l && mX<=r) && (mY>=t && mY<=b)); } function SetPointerPos(e) { //IE,NS //This function sets the mX and mY variables with the current position of the mouse pointer. //------------------------------ //e: Only used under Navigator, corresponds to the Event object. //------------------------------ //Version 1.0 // if(IE) { if(event==null) if(mFrame.window.event==null) return; else e = mFrame.window.event; else e = event; mX = e.clientX + mFrame.document.body.scrollLeft; mY = e.clientY + mFrame.document.body.scrollTop; } if(NS) { mX = e.pageX; mY = e.pageY; } } function HideMenus(e) { //IE,NS //This function checks if the mouse pointer is on a valid position and if the current menu should be kept visible. //The function is called every time the mouse pointer is moved over the document area. //------------------------------ //e: Only used under Navigator, corresponds to the Event object. //------------------------------ //Version 24.3 // SetPointerPos(e); if(nOM>0) if(OpenMenus[nOM].SelCommand!=null) while(!InMenu() && !HTHnd[nOM]) { HTHnd[nOM] = window.setTimeout("Hide()", HideSpeed); if(nOM==0) break; } } function FormsTweak(state) { //IE //This is an undocumented function, which can be used to hide every listbox (or combo) element on a page. //This can be useful if the menus will be displayed over an area where is a combo box, which is an element that cannot be placed behind the menus and it will always appear over the menus resulting in a very undesirable effect. //------------------------------ //Version 2.0 // if(DoFormsTweak && IE) for(var f = 0; f <= (mFrame.document.forms.length - 1); f++) for(var e = 0; e <= (mFrame.document.forms[f].elements.length - 1); e++) if(mFrame.document.forms[f].elements[e].type=="select-one") mFrame.document.forms[f].elements[e].style.visibility = state; } function execURL(url, tframe) { //IE,NS //This function is called every time a command is triggered to jump to another page or execute some javascript code. //------------------------------ //url: Encrypted URL that must be opened or executed. //tframe: If the url is a document location, tframe is the target frame where this document will be opened. //------------------------------ //Version 1.1 // HideAll(); window.setTimeout("execURL2('" + url + "', '" + tframe + "')", 100); } function execURL2(url, tframe) { //IE,NS //This function is called every time a command is triggered to jump to another page or execute some javascript code. //------------------------------ //url: Encrypted URL that must be opened or executed. //tframe: If the url is a document location, tframe is the target frame where this document will be opened. //------------------------------ //Version 1.0 // tframe = rStr(tframe); var fObj = eval(tframe); url = rStr(url); if(url.indexOf("javascript")!=url.indexOf("vbscript")) eval(url); else fObj.location.href = url; } function rStr(s) { //IE,NS //This function is used to decrypt the URL parameter from the triggered command. //------------------------------ //Version 1.1 // s = xrep(s,"\x1E","'"); s = xrep(s,"\x1D","\x22"); s = xrep(s,"\x1C",","); return s; } function xrep(s, f, n) { //IE,NS //This function looks for any occurrence of the f string and replaces it with the n string. //------------------------------ //Version 1.0 // var tmp = s.split(f); return tmp.join(n); } function hNSCClick(e) { //NS //This function executes the selected command's trigger code. //------------------------------ //Version 1.0 // eval(this.TCode); } function CBparseInt(n) { //NS //This function fixes a bug in Navigator's parseInt() function for the Mac. //------------------------------ //Version 1.0 // return IsMac?n:parseInt(n); } function HideAll() { //IE,NS //This function will hide all the currently opened menus. //------------------------------ //Version 1.0 // while(nOM>0) Hide(); } function GetLeftTop() { //IE,NS //This function returns the scroll bars position on the menus frame. //------------------------------ //Version 1.0 // if(IE) return [mFrame.document.body.scrollLeft,mFrame.document.body.scrollTop]; if(NS) return [mFrame.pageXOffset,mFrame.pageYOffset]; } function GetWidthHeight() { //IE,NS //This function returns the width and height of the menus frame. //------------------------------ //Version 1.0 // if(IE) return [mFrame.document.body.clientWidth,mFrame.document.body.clientHeight]; if(NS) return [mFrame.innerWidth,mFrame.innerHeight]; } function SetUpEvents() { //IE,NS //This function initializes the frame variables and setups the event handling. //------------------------------ //Version 1.2 // if(typeof(mFrame)=="undefined") //MENUFRAME if(typeof(mFrame)=="undefined") window.setTimeout("SetUpEvents()",10); else { if(NS) { mFrame.captureEvents(Event.MOUSEMOVE); mFrame.onmousemove = HideMenus; PrepareEvents(); } mFrame.document.onmousemove = HideMenus; document.onmousemove = HideMenus; } } function PrepareEvents() { //NS //This function is called right after the menus are rendered. //It has been designed to attach the OnClick event to the <layer> tag. This is being //done this way because Navigator does not support a click inline event capturing on //the layer tag... duh! //------------------------------ //Version 2.1 // for(var l=0; l<mFrame.document.layers.length; l++) { var lo = mFrame.document.layers[l]; lo.w = lo.clip.width; lo.h = lo.clip.height; for(var sl=0; sl<lo.layers.length; sl++) { var slo = mFrame.document.layers[l].layers[sl]; if(slo.name.indexOf("EH")>0) { slo.document.captureEvents(Event.CLICK); slo.document.onclick = hNSCClick; slo.document.TCode = nTCode[slo.name.split("EH")[1]]; } } } } //BROWSERCODE //EXPAND